const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

// type
const typeClassification = function (name) {
  let type = ''
  switch (name) {
    case '语文': type = 'Chinese'; break
    case '数学': type = 'Math'; break
    case "英语": type = 'English'; break
    case "物理": type = 'Physical'; break
    case "化学": type = 'Chemical'; break
    case '生物': type = 'Biological'; break
    case '政治': type = 'Bolitical'; break
    case "历史": type = 'History'; break
    case "地理": type = 'Geographic'; break
    default:
      type = '没有找到'
      break
  };
  return type
}
module.exports = {
  formatTime, typeClassification
}
